package com.shop2cn.iapi.sqdistributor.parameter.request.pojo;

import java.math.BigDecimal;
import java.util.Random;

public class DistributionAgencyLevelCommissionConfigVo {

	private Integer distributionConfigId;

	private Integer distributorLevelIndex;

	private String distributorLevelLabel;

	private BigDecimal layer1Rate;

	/**
	 * 分销机构与买家绑定有效期天数
	 */
	private int bindingEffectiveThreshold;

	/**
	 * 买家与分销员关系绑定规则类型(1：永久 2：可覆盖 3:有有效期限)
	 */
	private int userDistributorBindRuleType;

	public Integer getDistributionConfigId() {
		return distributionConfigId;
	}

	public void setDistributionConfigId(Integer distributionConfigId) {
		this.distributionConfigId = distributionConfigId;
	}

	public Integer getDistributorLevelIndex() {
		return distributorLevelIndex;
	}

	public void setDistributorLevelIndex(Integer distributorLevelIndex) {
		this.distributorLevelIndex = distributorLevelIndex;
	}

	public String getDistributorLevelLabel() {
		return distributorLevelLabel;
	}

	public void setDistributorLevelLabel(String distributorLevelLabel) {
		this.distributorLevelLabel = distributorLevelLabel;
	}

	public BigDecimal getLayer1Rate() {
		return layer1Rate;
	}

	public void setLayer1Rate(BigDecimal layer1Rate) {
		this.layer1Rate = layer1Rate;
	}

	public int getBindingEffectiveThreshold() {
		return bindingEffectiveThreshold;
	}

	public void setBindingEffectiveThreshold(int bindingEffectiveThreshold) {
		this.bindingEffectiveThreshold = bindingEffectiveThreshold;
	}

	public int getUserDistributorBindRuleType() {
		return userDistributorBindRuleType;
	}

	public void setUserDistributorBindRuleType(int userDistributorBindRuleType) {
		this.userDistributorBindRuleType = userDistributorBindRuleType;
	}

	public static DistributionAgencyLevelCommissionConfigVo createStandardDistributorLevelCommissionConfig(
			int agencyType) {

		DistributionAgencyLevelCommissionConfigVo distributionAgencyLevelCommissionConfigVo = new DistributionAgencyLevelCommissionConfigVo();

		distributionAgencyLevelCommissionConfigVo.setDistributionConfigId(1);
		distributionAgencyLevelCommissionConfigVo.setDistributorLevelIndex(0);
		distributionAgencyLevelCommissionConfigVo
				.setDistributorLevelLabel("autotestLabel");
		distributionAgencyLevelCommissionConfigVo.setLayer1Rate(new BigDecimal(
				new Random().nextInt(20) + 1).multiply(new BigDecimal("0.01"))
				.setScale(2));
		
//		distributionAgencyLevelCommissionConfigVo.setLayer1Rate(BigDecimal.ZERO);

		if (agencyType == 1) {

			distributionAgencyLevelCommissionConfigVo
					.setUserDistributorBindRuleType(1);
			distributionAgencyLevelCommissionConfigVo
					.setBindingEffectiveThreshold(100);
		}

		return distributionAgencyLevelCommissionConfigVo;
	}

	public DistributionAgencyLevelCommissionConfigVo withUserDistributorBindRuleType(
			int userDistributorBindRuleType) {

		this.userDistributorBindRuleType = userDistributorBindRuleType;

		return this;
	}

	public DistributionAgencyLevelCommissionConfigVo withBindingEffectiveThreshold(
			int bindingEffectiveThreshold) {

		this.bindingEffectiveThreshold = bindingEffectiveThreshold;

		return this;
	}
}
